Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Management Navigator Supervisor Backend Implementation #120

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

sanjaytkbabu
Copy link
Contributor

@sanjaytkbabu sanjaytkbabu commented Jul 23, 2024

Description

PADS-222
User Management - Supervisor backend implementation
features - create new user, revoke user, manage user (will be functional after rbac)
migration added for access_request table

Types of changes

New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

github-actions bot commented Jul 23, 2024

Coverage Report (Application)

Totals Coverage
Statements: 44.58% ( 938 / 2104 )
Methods: 34.02% ( 132 / 388 )
Lines: 55.25% ( 616 / 1115 )
Branches: 31.61% ( 190 / 601 )

Copy link

github-actions bot commented Jul 23, 2024

Coverage Report (Frontend)

Totals Coverage
Statements: 30.91% ( 1454 / 4704 )
Methods: 26.92% ( 249 / 925 )
Lines: 35.42% ( 899 / 2538 )
Branches: 24.66% ( 306 / 1241 )

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 5 times, most recently from 4755dc1 to 6021eea Compare July 24, 2024 15:24
@Subin1Doo
Copy link

Things are looking great! Few comments..
For the status can we say "what" it's pending. So it would either say "Pending approval" or "Pending revocation."
And for the Create new user modal, can we make sure everything is left / right aligned. Thanks!

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch from 6021eea to 92b460a Compare July 24, 2024 16:54
@sanjaytkbabu
Copy link
Contributor Author

Things are looking great! Few comments.. For the status can we say "what" it's pending. So it would either say "Pending approval" or "Pending revocation." And for the Create new user modal, can we make sure everything is left / right aligned. Thanks!

done!

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch from 92b460a to 1472961 Compare July 24, 2024 17:12
@Subin1Doo
Copy link

Sorry just double checking, once the pending revocation has been approved by the admin the status should say "revoked" in the Nav supervisor view. "Approved" for new user approval.

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch from 1472961 to 20989b3 Compare July 24, 2024 17:47
@sanjaytkbabu
Copy link
Contributor Author

Sorry just double checking, once the pending revocation has been approved by the admin the status should say "revoked" in the Nav supervisor view. "Approved" for new user approval.

yes, that's correct

@sanjaytkbabu sanjaytkbabu marked this pull request as ready for review July 24, 2024 17:59
@sanjaytkbabu sanjaytkbabu requested a review from jujaga July 24, 2024 18:58
@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 2 times, most recently from 678ac54 to b255a96 Compare July 25, 2024 16:23

import type { Stamps } from '../stamps';
import type { AccessRequest } from '../../types/AccessRequest'; // Import the access_request_status_enum type
import { UserStatus } from '../../utils/enums/application';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import ordering

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching


const trxWrapper = (etrx: Prisma.TransactionClient | undefined = undefined) => (etrx ? etrx : prisma);

// Constants
const SYSTEM_USER = 'system';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYSTEM_USER should be checked by it's guid, which is NIL, not name.
const SYSTEM_USER = NIL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -10,4 +12,5 @@ export type User = {
fullName: string | null;
lastName: string | null;
active: boolean;
accessRequest?: AccessRequest | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User and AccessRequest are different concepts. It doesn't feel right that they are combined like this.

* @returns {Promise<object>} The result of running the insert operation
* @throws The error encountered upon db transaction failure
*/
createUserAccessRequest: async (data: User) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per lower comment, user and AccessRequest are different concepts. Function should take two different parameters.

Comment on lines 184 to 190
/**
* @function listNavigators
* Lists all the
* @param {boolean} [active] Optional boolean on user active status
* @returns {Promise<object>} The result of running the find operation
*/
getNavsAndAccessRequests: async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDoc needs to be fixed. And function name isn't accurate as it's not limited to just the Navs. getLatestAccessRequests is more appropriate.

Comment on lines 400 to 405
/**
* @function revokeUserAccessRequest
* Updates user access
* @returns {Promise<object>} The result of running the put operation
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect JSDoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching

* @returns {Promise<object>} The result of running the put operation
*/
updateUserRole: async (user: User) => {
console.log(user);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just put it there to stop unused 'user' variable complaints. I've removed it!

@@ -30,6 +30,11 @@ export enum Initiative {
HOUSING = 'HOUSING'
}

export enum UserStatus {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misnomer. This is the status of the access request, not the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Comment on lines 37 to 39
}
export enum Regex {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Please ensure new lines are between blocks. I've noticed this a few times within this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 2 times, most recently from 094a6cc to 2c4df1f Compare August 1, 2024 17:30
@sanjaytkbabu sanjaytkbabu requested a review from kyle1morel August 1, 2024 17:39
@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch from 2c4df1f to 5b617b0 Compare August 1, 2024 17:44
@sanjaytkbabu sanjaytkbabu reopened this Aug 1, 2024
@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 2 times, most recently from 6296b20 to 11b21df Compare August 1, 2024 21:09
response = await service.createUser(data, trx);
});
return user.fromPrismaModel(response);
} else return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transaction not required at this level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 2 times, most recently from bae93d4 to cb78639 Compare August 2, 2024 21:44
@Subin1Doo
Copy link

Comment on the sorting of the "status" column.
When I sort this column, it doesn't really seem to be sorting. The order seems rather random.
Can we make it so that when they sort by "status" it shows the pending approval ones first, then the pending revocation ones, then all the approved ones? and the other way around. Thank you!

@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch 2 times, most recently from 0899735 to 771576a Compare August 4, 2024 03:08
@sanjaytkbabu sanjaytkbabu force-pushed the feature/nav-supervisor-be branch from 771576a to 1b74a32 Compare August 4, 2024 03:17
@sanjaytkbabu
Copy link
Contributor Author

Comment on the sorting of the "status" column. When I sort this column, it doesn't really seem to be sorting. The order seems rather random. Can we make it so that when they sort by "status" it shows the pending approval ones first, then the pending revocation ones, then all the approved ones? and the other way around. Thank you!

As discussed went with PR, PA & A.

Copy link
Collaborator

@kyle1morel kyle1morel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed semantically. Lots of file changes, difficult to follow the full logic. Functionality looks to be there.

@kyle1morel kyle1morel merged commit 0d30d7d into release/user-management Aug 8, 2024
16 of 17 checks passed
@kyle1morel kyle1morel deleted the feature/nav-supervisor-be branch August 8, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants